package com.erpanderp.wam.ac.view.project;
	
	import java.io.Serializable;
	import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
	import java.util.Date;
	import java.util.HashMap;
	import java.util.List;
	import java.util.Map;
	
	import javax.faces.application.FacesMessage;
	import javax.faces.bean.ManagedBean;
	import javax.faces.bean.ViewScoped;
	import javax.faces.context.FacesContext;
	import javax.faces.event.AjaxBehaviorEvent;
	import javax.security.auth.message.callback.PrivateKeyCallback.Request;
	import javax.servlet.ServletContext;
	import javax.servlet.http.HttpServletRequest;
	import javax.servlet.http.HttpSession;
	import javax.swing.SwingWorker;
	
	import org.primefaces.component.selectonemenu.SelectOneMenu;
	import org.primefaces.context.RequestContext;
	
	import com.erpanderp.wam.ac.model.entity.project.ProjectAssignment;
	import com.erpanderp.wam.ac.model.entity.project.ProjectAssignmentDetail;
	import com.erpanderp.wam.ac.model.service.project.ProjectAssignmentDAO;
	import com.erpanderp.wam.ac.model.service.project.ProjectAssignmentDetailDAO;
	import com.erpanderp.wam.tm.model.service.RRFDAO;
import com.erpanderp.wam.usm.model.entity.projectandassignment.EmployeeProject;
	import com.erpanderp.wam.usm.model.entity.projectandassignment.Project;
	import com.erpanderp.wam.usm.model.entity.user.Employee;
	import com.erpanderp.wam.usm.model.entity.user.EmployeeAndReporting;
	import com.erpanderp.wam.usm.model.entity.user.WAMUser;
import com.erpanderp.wam.usm.model.service.projectandassignment.EmployeeProjectDAO;
	import com.erpanderp.wam.usm.model.service.projectandassignment.ProjectDAO;
	import com.erpanderp.wam.util.CommonLookup;
	import com.erpanderp.wam.util.EmailUtil;
	import com.erpanderp.wam.util.ValidationUtil;
import com.erpanderp.wam.util.WAMHostManager;
	@ManagedBean
	@ViewScoped
	public class ApproveDomesticProjectAssignmentBean implements Serializable {
	private static final long serialVersionUID = 1L;
	HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
	.getExternalContext().getSession(true);
	HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
	ServletContext context = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
	
	ProjectDAO projectDAO = new ProjectDAO();
	ProjectAssignmentDAO projectAssignmentDAO = new ProjectAssignmentDAO();
	ProjectAssignmentDetailDAO projectAssignmentDetailDAO = new ProjectAssignmentDetailDAO();
	
	private ProjectAssignment projectAssignment = new ProjectAssignment();
	private ProjectAssignmentDetail projectAssignmentDetail = new ProjectAssignmentDetail();
	private Employee employee = new Employee();
	private Project selectedProject= new Project();
	private WAMUser wamUser = (WAMUser) session.getAttribute(CommonLookup.SESSION_ATTRIBUTE_WAMUSER);
	private Employee reportingManager;
	private EmailUtil emailUtil = new EmailUtil();
	
	private boolean SHOW_EDIT_DIALOG=false;
	private boolean FORM_VALID;
	private boolean renderApprove;
	private boolean renderRecommend;
	private boolean renderReject;
	
	private List<ProjectAssignment> projectAssignmentsList = new ArrayList<ProjectAssignment>();
	private List<ProjectAssignmentDetail> projectAssignmentDetailList = new ArrayList<ProjectAssignmentDetail>();
	private List<Project> projects = new ArrayList<Project>();
	
	EmployeeProjectDAO employeeProjectDAO = new EmployeeProjectDAO();
	
	private EmployeeProject  employeeProject = new EmployeeProject();
	private List<EmployeeProject> employeeProjects = new ArrayList<EmployeeProject>();
	
	Map<String, Long> projectsMap = new HashMap<String, Long>();
	
	private Long projectAssignmentId;
	
	private Long selectedProjectId;
	
	private String projectAssignmentCode;
	private String employeeId;
	private String contactNumber="";
	private String approvedBy="";
	private Float advanceAmount;
	private Float roomRentAdvance;
	private Date createDate;
	private String additionals;
	String EMAIL_MESSAGE;
	
	public ApproveDomesticProjectAssignmentBean() 
	{
	// TODO Auto-generated constructor stub
	projectAssignmentId = Long.parseLong(request.getParameter("projectAssignmentId"));
	System.out.println("constructor start.................");
	System.out.println("projectAssignmentId......................"+projectAssignmentId);

	projectAssignment = projectAssignmentDAO.getProjectAssignmentByProjectAssignmentId(projectAssignmentId);
	
	List<ProjectAssignmentDetail> tempList = new ArrayList<ProjectAssignmentDetail>();
	tempList.addAll(projectAssignment.getProjectAssignmentDetails());
	projectAssignmentDetail = tempList.get(0);
	 
	if(projectAssignment.getRecommendationStatus().equals("INPROCESS") && projectAssignment.getApprovalStatus().equals("INPROCESS"))
	{
	System.out.println("recommended1..........."+projectAssignment.getRecommendationStatus());
	System.out.println("approve1..........."+projectAssignment.getApprovalStatus());
	setRenderRecommend(true);
	setRenderApprove(false);
	setRenderReject(true);
	}
	if(projectAssignment.getRecommendationStatus().equals("RECOMMENDED") && projectAssignment.getApprovalStatus().equals("INPROCESS"))
	{
	System.out.println("recommended2..........."+projectAssignment.getRecommendationStatus());
	System.out.println("approve2..........."+projectAssignment.getApprovalStatus());
	setRenderRecommend(false);
	setRenderApprove(true);
	setRenderReject(true);
	}
	
	employeeProjects = employeeProjectDAO.getAllEmployeeProjects(wamUser.getEmployee().getEmployeeId());
	  for(EmployeeProject employeeProject :employeeProjects)
	  {
		  projectsMap.put(employeeProject.getProject().getProjectName(), employeeProject.getProject().getProjectId());
	  }
	
	System.out.println("constructor end...................");
	}
	
	
	
	public void projectChangeListener(AjaxBehaviorEvent e) 
	{
	selectedProjectId = Long.parseLong(((SelectOneMenu)e.getComponent()).getValue().toString());
	System.out.println(selectedProjectId);
	projectAssignment.setProject(projectDAO.getProjectByProjectID(selectedProjectId));
	 }
	
	public void advanceAmountChangeListener(AjaxBehaviorEvent e)
	{
	advanceAmount = projectAssignmentDetail.getAdvanceAmount();
	projectAssignmentDetail.setTotalAdvance(advanceAmount);
	System.out.println("getTotalAdvance.`..........11111111: " + projectAssignmentDetail.getTotalAdvance());
	
	} 
	
	public void roomRentAdvanceChangeListener(AjaxBehaviorEvent e){
	advanceAmount = projectAssignmentDetail.getAdvanceAmount();
	roomRentAdvance = projectAssignmentDetail.getRoomRentAdvance();
	projectAssignmentDetail.setTotalAdvance(advanceAmount+roomRentAdvance);
	System.out.println("getTotalAdvance............2222222222: " + projectAssignmentDetail.getTotalAdvance());
	
	}
	
	//RECOMMEND ACTION
	public String recommendDomesticProjectAssignment()
	{
		System.out.println("In  recommendDomesticProjectAssignment");
		validateFormRecommend();
		if(FORM_VALID){
			
			setEmailUtil(new EmailUtil());
 			projectAssignment.setRecommendationStatus(CommonLookup.PROJECT_ASSIGNMENT_RECOMMENDATIONSTATUS_STATUS);
			projectAssignmentDetail.setRecommendationStatus(CommonLookup.PROJECT_ASSIGNMENT_RECOMMENDATIONSTATUS_STATUS);
			projectAssignment.setRecommendationRemarks(projectAssignment.getRecommendationRemarks());
			projectAssignmentDetail.setRecommendationRemarks(projectAssignment.getRecommendationRemarks());
			if(projectAssignmentDAO.updateProjectAssignment(projectAssignment) != null ){
 			System.out.println("In recommend success....");
 			System.out.println("AT CALLER METHOD: " + sendMessage());
 			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, projectAssignment.getProjectAssignmentId() + " ProjectAssignment recommended successfully.", ""));
 			
			System.out.println("In recommend success....after");
			projectAssignment = new ProjectAssignment();
			projectAssignment.setProject(new Project());
			}else{
 				FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Failed to recommend ProjectAssignment.", ""));
 			}
	}
	return null;
	}
	
	//RECOMMEND MAIL
	public String sendMessage(){
		Map<String, String> hostsMap = WAMHostManager.getWAMHosts(context);
		String domainName = context.getInitParameter("domainName");
		
		if(hostsMap.get(CommonLookup.DEV_EMAIL) == null){
			String[] to = {CommonLookup.PROJECTASSIGNMENT_DOMESTIC_INTERNATIONAL_APPROVER_EMAIL};
			emailUtil.setRecieverAddresses(to);
		}else{
			String[] to = {hostsMap.get(CommonLookup.DEV_EMAIL)};
			emailUtil.setRecieverAddresses(to);
		}
		 
		String requestURL = "ac/project/approvedomesticprojectassignment.html";
		String privateLink = "http://" + hostsMap.get(CommonLookup.PRIVATEHOST) + "/" + domainName + "/" + requestURL+"?projectAssignmentId="+projectAssignment.getProjectAssignmentId()+"&RECOMMENDATIONSTATUS="+CommonLookup.PROJECT_ASSIGNMENT_RECOMMENDATIONSTATUS_STATUS;
		String publicLink = "http://" + hostsMap.get(CommonLookup.PUBLICHOST) + "/"	+ domainName + "/" + requestURL+"?projectAssignmentId="+projectAssignment.getProjectAssignmentId()+"&RECOMMENDATIONSTATUS="+CommonLookup.PROJECT_ASSIGNMENT_RECOMMENDATIONSTATUS_STATUS;
		String messageString = "Dear " + CommonLookup.PROJECTASSIGNMENT_DOMESTIC_INTERNATIONAL_APPROVER + ",<br /><br />" + 
					"<a style='color:#FF9933;font-weight: bold;' href=\""+
					privateLink + "\">" + "Please click here to approve/reject domestic project assignment"+" "+projectAssignment.getProjectAssignmentCode() + "</a /><br /><br />"+
					"(Employees who are in Hyderabad office)"+"<br /><br />"+
					"<a style='color:#FF9933;font-weight: bold;' href=\""+
					publicLink + "\">" + "Please click here to approve/reject domestic project assignment"+" "+projectAssignment.getProjectAssignmentCode() + "</a /><br />"+
					"(Out side of Hyderabad office)"+"<br /><br />"+

				    "Thanks & Regards, <br />"
				    + CommonLookup.WAM_DEVTEAM_SIGNATURE;
		 
	
		emailUtil.setMessage(messageString);
		
		emailUtil.setSenderEmail("podquick@erpanderp.com", "WAM - Dev Team");
		emailUtil.setSubject("Domestic project assignment request-"+projectAssignment.getProjectAssignmentCode());

		SwingWorker worker = new SwingWorker<String, Object>() {
			@Override
			protected String doInBackground() throws Exception {
				EMAIL_MESSAGE = emailUtil.processAndSendEmail();
				return null;
			}

			@Override
			protected void done() {
					System.out.println("DONE " + EMAIL_MESSAGE);		
			}
		};
		worker.execute();
		System.out.println( "BEFORE RETURNING: " + EMAIL_MESSAGE);
		return EMAIL_MESSAGE;
	}
	
	//APPROVE ACTION
	public String approveDomesticProjectAssignment()
	{
		System.out.println("In  approveDomesticProjectAssignment");
		validateFormApprove();
		if(FORM_VALID){
			
 			projectAssignment.setApprovalStatus(CommonLookup.PROJECT_ASSIGNMENT_APPROVED_STATUS);
			projectAssignmentDetail.setApprovalStatus(CommonLookup.PROJECT_ASSIGNMENT_APPROVED_STATUS);
			projectAssignment.setApprovalRemarks(projectAssignment.getApprovalRemarks());
			projectAssignmentDetail.setApprovalRemarks(projectAssignment.getApprovalRemarks());
			if(projectAssignmentDAO.updateProjectAssignment(projectAssignment) != null ){
 			System.out.println("In approve success....");
 			System.out.println("AT CALLER METHOD: " + sendMessageApprove());
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, projectAssignment.getProjectAssignmentId() + " ProjectAssignment approved successfully.", ""));
			System.out.println("In approve success....after");
			projectAssignment = new ProjectAssignment();
			projectAssignment.setProject(new Project());
			}else{
 				FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Failed to approve ProjectAssignment.", ""));
 			}
		}
		return null;
	}
	
	//APPROVE MAIL
	public String sendMessageApprove(){
		Map<String, String> hostsMap = WAMHostManager.getWAMHosts(context);
		String domainName = context.getInitParameter("domainName");
		if(hostsMap.get(CommonLookup.DEV_EMAIL) == null){
			String[] to = {projectAssignment.getEmployee().getEmail()};
			emailUtil.setRecieverAddresses(to);
		}else{
			String[] to = {hostsMap.get(CommonLookup.DEV_EMAIL)};
			emailUtil.setRecieverAddresses(to);
		} 
		String requestURL = "ac/project/approvedomesticprojectassignment.html";
		String privateLink = "http://" + hostsMap.get(CommonLookup.PRIVATEHOST) + "/" + domainName + "/" + requestURL+"?projectAssignmentId="+projectAssignment.getProjectAssignmentId()+"&RECOMMENDATIONSTATUS="+CommonLookup.PROJECT_ASSIGNMENT_RECOMMENDATIONSTATUS_STATUS;
		String publicLink = "http://" + hostsMap.get(CommonLookup.PUBLICHOST) + "/"	+ domainName + "/" + requestURL+"?projectAssignmentId="+projectAssignment.getProjectAssignmentId()+"&RECOMMENDATIONSTATUS="+CommonLookup.PROJECT_ASSIGNMENT_RECOMMENDATIONSTATUS_STATUS;
		String messageString = "Dear " + projectAssignment.getEmployee().getFirstName()+" "+projectAssignment.getEmployee().getLastName() + ",<br /><br />" + 
					"<a style='color:#FF9933;font-weight: bold;'>" + "Your domestic project assignment-"+" "+projectAssignment.getProjectAssignmentCode() +
					" "+"is approved"+"<br /><br />"+

				    "Thanks & Regards, <br />"
				    + CommonLookup.WAM_DEVTEAM_SIGNATURE;
		 
	
		emailUtil.setMessage(messageString);
		emailUtil.setSenderEmail("podquick@erpanderp.com", "WAM - Dev Team");
		emailUtil.setSubject("Domestic project assignment request-"+projectAssignment.getProjectAssignmentCode());

		SwingWorker worker = new SwingWorker<String, Object>() {
			@Override
			protected String doInBackground() throws Exception {
				EMAIL_MESSAGE = emailUtil.processAndSendEmail();
				return null;
			}

			@Override
			protected void done() {
					System.out.println("DONE " + EMAIL_MESSAGE);		
			}
		};
		worker.execute();
		System.out.println( "BEFORE RETURNING: " + EMAIL_MESSAGE);
		return EMAIL_MESSAGE;
	}

	//REJECT ACTION
	public String rejectDomesticProjectAssignment()
	{
		System.out.println("In  rejectDomesticProjectAssignment");
		validateFormReject();
		if(FORM_VALID){
			
 			projectAssignment.setRecommendationStatus(CommonLookup.PROJECT_ASSIGNMENT_REJECTIONSTATUS_STATUS);
			projectAssignmentDetail.setRecommendationStatus(CommonLookup.PROJECT_ASSIGNMENT_REJECTIONSTATUS_STATUS);
			projectAssignment.setApprovalStatus(CommonLookup.PROJECT_ASSIGNMENT_REJECTIONSTATUS_STATUS);
			projectAssignmentDetail.setApprovalStatus(CommonLookup.PROJECT_ASSIGNMENT_REJECTIONSTATUS_STATUS);
			projectAssignment.setRecommendationRemarks(projectAssignment.getRecommendationRemarks());
			projectAssignmentDetail.setRecommendationRemarks(projectAssignment.getRecommendationRemarks());
			projectAssignment.setApprovalRemarks(projectAssignment.getApprovalRemarks());
			projectAssignmentDetail.setApprovalRemarks(projectAssignment.getApprovalRemarks());
			if(projectAssignmentDAO.updateProjectAssignment(projectAssignment) != null ){
 			System.out.println("In reject success....");
 			System.out.println("AT CALLER METHOD: " + sendMessageReject());
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, projectAssignment.getProjectAssignmentId() + " ProjectAssignment rejected successfully.", ""));
			System.out.println("In reject success....after");
			projectAssignment = new ProjectAssignment();
			projectAssignment.setProject(new Project());
			}else{
 				FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Failed to reject ProjectAssignment.", ""));
 			}
		}
		return null;
	}
	
	//REJECT MAIL
	public String sendMessageReject(){
		Map<String, String> hostsMap = WAMHostManager.getWAMHosts(context);
		String domainName = context.getInitParameter("domainName");
		if(hostsMap.get(CommonLookup.DEV_EMAIL) == null){
			String[] to = {projectAssignment.getEmployee().getEmail()};
			emailUtil.setRecieverAddresses(to);
		}else{
			String[] to = {hostsMap.get(CommonLookup.DEV_EMAIL)};
			emailUtil.setRecieverAddresses(to);
		}
		String requestURL = "ac/project/approvedomesticprojectassignment.html";
		String privateLink = "http://" + hostsMap.get(CommonLookup.PRIVATEHOST) + "/" + domainName + "/" + requestURL+"?projectAssignmentId="+projectAssignment.getProjectAssignmentId()+"&RECOMMENDATIONSTATUS="+CommonLookup.PROJECT_ASSIGNMENT_RECOMMENDATIONSTATUS_STATUS;
		String publicLink = "http://" + hostsMap.get(CommonLookup.PUBLICHOST) + "/"	+ domainName + "/" + requestURL+"?projectAssignmentId="+projectAssignment.getProjectAssignmentId()+"&RECOMMENDATIONSTATUS="+CommonLookup.PROJECT_ASSIGNMENT_RECOMMENDATIONSTATUS_STATUS;
		String messageString = "Dear " + projectAssignment.getEmployee().getFirstName()+" "+projectAssignment.getEmployee().getLastName() + ",<br /><br />" + 
					"<a style='color:#FF9933;font-weight: bold;'>" + "Your domestic project assignment-"+" "+projectAssignment.getProjectAssignmentCode() +
					" "+"is rejected.Please resubmit again"+"<br /><br />"+

				    "Thanks & Regards, <br />"
				    + CommonLookup.WAM_DEVTEAM_SIGNATURE;
		 
	
		emailUtil.setMessage(messageString);
		emailUtil.setSenderEmail("podquick@erpanderp.com", "WAM - Dev Team");
		emailUtil.setSubject("Domestic project assignment request-"+projectAssignment.getProjectAssignmentCode());

		SwingWorker worker = new SwingWorker<String, Object>() {
			@Override
			protected String doInBackground() throws Exception {
				EMAIL_MESSAGE = emailUtil.processAndSendEmail();
				return null;
			}

			@Override
			protected void done() {
					System.out.println("DONE " + EMAIL_MESSAGE);		
			}
		};
		worker.execute();
		System.out.println( "BEFORE RETURNING: " + EMAIL_MESSAGE);
		return EMAIL_MESSAGE;
	}
	
	//VALIDATION
	private void validateFormRecommend(){
	System.out.println("validateForm.....................");
	FORM_VALID = true;
	if(ValidationUtil.isEmpty(projectAssignment.getEmergencycontactNumber(), "Emergency Contact Number ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	
	if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getDailyAllowance()), "Daily Allowance(INR) ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getAdvanceAmount()), "Advance Amount(INR) ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	if(ValidationUtil.isEmpty(projectAssignmentDetail.getAdvanceByDate() != null ? projectAssignmentDetail.getAdvanceByDate().toString() :null , "Advance Amount By Date ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	if(ValidationUtil.isEmpty(projectAssignmentDetail.getPaymentCycleDate() != null ? projectAssignmentDetail.getPaymentCycleDate().toString() :null , "Payment Cycle [Date of every month] ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getAdditionals()), "Additionals ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getRoomRentAdvance()), "Room Rent Advance ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getRoomRentPerMonth()), "Room Rent Per Month ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getTotalAdvance()), "Total Amount ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	if(ValidationUtil.isEmpty(projectAssignment.getRecommendationRemarks(), "Recommender's Remarks ", null, FacesContext.getCurrentInstance()) != null){
		FORM_VALID = false;
	}
	System.out.println("Finally FORM_VALID is :::::"+FORM_VALID);
	}
	
	private void validateFormApprove(){
		System.out.println("validateForm.....................");
		FORM_VALID = true;
		if(ValidationUtil.isEmpty(projectAssignment.getEmergencycontactNumber(), "Emergency Contact Number ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getDailyAllowance()), "Daily Allowance(INR) ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getAdvanceAmount()), "Advance Amount(INR) ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(projectAssignmentDetail.getAdvanceByDate() != null ? projectAssignmentDetail.getAdvanceByDate().toString() :null , "Advance Amount By Date ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(projectAssignmentDetail.getPaymentCycleDate() != null ? projectAssignmentDetail.getPaymentCycleDate().toString() :null , "Payment Cycle [Date of every month] ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getAdditionals()), "Additionals ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getRoomRentAdvance()), "Room Rent Advance ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getRoomRentPerMonth()), "Room Rent Per Month ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getTotalAdvance()), "Total Amount ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(projectAssignment.getApprovalRemarks(), "Approver's Remarks ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		System.out.println("Finally FORM_VALID is :::::"+FORM_VALID);
		}
	private void validateFormReject(){
		System.out.println("validateForm.....................");
		FORM_VALID = true;
		if(ValidationUtil.isEmpty(projectAssignment.getEmergencycontactNumber(), "Emergency Contact Number ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getDailyAllowance()), "Daily Allowance(INR) ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getAdvanceAmount()), "Advance Amount(INR) ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(projectAssignmentDetail.getAdvanceByDate() != null ? projectAssignmentDetail.getAdvanceByDate().toString() :null , "Advance Amount By Date ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(projectAssignmentDetail.getPaymentCycleDate() != null ? projectAssignmentDetail.getPaymentCycleDate().toString() :null , "Payment Cycle [Date of every month] ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getAdditionals()), "Additionals ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getRoomRentAdvance()), "Room Rent Advance ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getRoomRentPerMonth()), "Room Rent Per Month ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(String.valueOf(projectAssignmentDetail.getTotalAdvance()), "Total Amount ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		if(ValidationUtil.isEmpty(projectAssignment.getApprovalRemarks(), "Approver's Remarks ", null, FacesContext.getCurrentInstance()) != null || ValidationUtil.isEmpty(projectAssignment.getRecommendationRemarks(), "Recommender's Remarks ", null, FacesContext.getCurrentInstance()) != null){
			FORM_VALID = false;
		}
		System.out.println("Finally FORM_VALID is :::::"+FORM_VALID);
		}
	//GETTERS AND SETTERS
	public HttpSession getSession() {
	return session;
	}
	
	public void setSession(HttpSession session) {
	this.session = session;
	}
	
	public ProjectDAO getProjectDAO() {
	return projectDAO;
	}
	
	public void setProjectDAO(ProjectDAO projectDAO) {
	this.projectDAO = projectDAO;
	}
	
	public ProjectAssignmentDAO getProjectAssignmentDAO() {
	return projectAssignmentDAO;
	}
	
	public void setProjectAssignmentDAO(ProjectAssignmentDAO projectAssignmentDAO) {
	this.projectAssignmentDAO = projectAssignmentDAO;
	}
	
	public Long getProjectAssignmentId() {
	return projectAssignmentId;
	}
	
	public void setProjectAssignmentId(Long projectAssignmentId) {
	this.projectAssignmentId = projectAssignmentId;
	}
	
	public List<ProjectAssignment> getProjectAssignmentsList() {
	return projectAssignmentsList;
	}
	
	public void setProjectAssignmentsList(List<ProjectAssignment> projectAssignmentsList) {
	this.projectAssignmentsList = projectAssignmentsList;
	}
	
	
	public ProjectAssignment getProjectAssignment() {
	return projectAssignment;
	}
	
	public void setProjectAssignment(ProjectAssignment projectAssignment) {
	this.projectAssignment = projectAssignment;
	}
	
	public ProjectAssignmentDetail getProjectAssignmentDetail() {
	return projectAssignmentDetail;
	}
	
	public void setProjectAssignmentDetail(ProjectAssignmentDetail projectAssignmentDetail) {
	this.projectAssignmentDetail = projectAssignmentDetail;
	}
	
	public Employee getEmployee() {
	return employee;
	}
	
	public void setEmployee(Employee employee) {
	this.employee = employee;
	}
	
	
	
	
	public List<ProjectAssignmentDetail> getProjectAssignmentDetailList() {
	return projectAssignmentDetailList;
	}
	
	public void setProjectAssignmentDetailList(
	List<ProjectAssignmentDetail> projectAssignmentDetailList) {
	this.projectAssignmentDetailList = projectAssignmentDetailList;
	}
	
	public String getEmployeeId() {
	return employeeId;
	}
	
	public void setEmployeeId(String employeeId) {
	this.employeeId = employeeId;
	}
	public boolean isSHOW_EDIT_DIALOG() {
	return SHOW_EDIT_DIALOG;
	}
	public void setSHOW_EDIT_DIALOG(boolean sHOW_EDIT_DIALOG) {
	SHOW_EDIT_DIALOG = sHOW_EDIT_DIALOG;
	}
	
	public boolean isFORM_VALID() {
	return FORM_VALID;
	}
	
	
	
	
	public void setFORM_VALID(boolean fORM_VALID) {
	FORM_VALID = fORM_VALID;
	}
	
	
	
	
	public Project getSelectedProject() {
	return selectedProject;
	}
	
	
	
	
	public void setSelectedProject(Project selectedProject) {
	this.selectedProject = selectedProject;
	}
	
	
	
	
	public WAMUser getWamUser() {
	return wamUser;
	}
	
	
	
	
	public void setWamUser(WAMUser wamUser) {
	this.wamUser = wamUser;
	}
	
	
	
	
	public String getProjectAssignmentCode() {
	return projectAssignmentCode;
	}
	
	
	
	
	public void setProjectAssignmentCode(String projectAssignmentCode) {
	this.projectAssignmentCode = projectAssignmentCode;
	}
	
	
	
	
	public String getContactNumber() {
	return contactNumber;
	}
	
	
	
	
	public void setContactNumber(String contactNumber) {
	this.contactNumber = contactNumber;
	}
	
	
	
	
	public String getApprovedBy() {
	return approvedBy;
	}
	
	
	
	
	public void setApprovedBy(String approvedBy) {
	this.approvedBy = approvedBy;
	}
	
	
	
	
	public Float getAdvanceAmount() {
	return advanceAmount;
	}
	
	
	
	
	public void setAdvanceAmount(Float advanceAmount) {
	this.advanceAmount = advanceAmount;
	}
	
	
	
	
	public Float getRoomRentAdvance() {
	return roomRentAdvance;
	}
	
	
	
	
	public void setRoomRentAdvance(Float roomRentAdvance) {
	this.roomRentAdvance = roomRentAdvance;
	}
	
	
	
	
	public Date getCreateDate() {
	return createDate;
	}
	
	
	
	
	public void setCreateDate(Date createDate) {
	this.createDate = createDate;
	}
	
	
	
	
	public Employee getReportingManager() {
	return reportingManager;
	}
	
	
	
	
	public void setReportingManager(Employee reportingManager) {
	this.reportingManager = reportingManager;
	}
	
	
	
	
	public String getAdditionals() {
	return additionals;
	}
	
	
	
	
	public void setAdditionals(String additionals) {
	this.additionals = additionals;
	}
	
	

	
	public Long getSelectedProjectId() {
	return selectedProjectId;
	}
	
	public void setSelectedProjectId(Long selectedProjectId) {
	this.selectedProjectId = selectedProjectId;
	}
	public ProjectAssignmentDetailDAO getProjectAssignmentDetailDAO() {
	return projectAssignmentDetailDAO;
	}
	
	public void setProjectAssignmentDetailDAO(
	ProjectAssignmentDetailDAO projectAssignmentDetailDAO) {
	this.projectAssignmentDetailDAO = projectAssignmentDetailDAO;
	}
	
	public List<Project> getProjects() {
	return projects;
	}
	
	public void setProjects(List<Project> projects) {
	this.projects = projects;
	}
	
	public Map<String, Long> getProjectsMap() {
	return projectsMap;
	}
	
	public void setProjectsMap(Map<String, Long> projectsMap) {
	this.projectsMap = projectsMap;
	}
	




	public boolean isRenderApprove() {
		return renderApprove;
	}



	public void setRenderApprove(boolean renderApprove) {
		this.renderApprove = renderApprove;
	}



	public boolean isRenderRecommend() {
		return renderRecommend;
	}



	public void setRenderRecommend(boolean renderRecommend) {
		this.renderRecommend = renderRecommend;
	}



	public EmailUtil getEmailUtil() {
		return emailUtil;
	}



	public void setEmailUtil(EmailUtil emailUtil) {
		this.emailUtil = emailUtil;
	}
	public HttpServletRequest getRequest() {
		return request;
	}



	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}



	public ServletContext getContext() {
		return context;
	}



	public void setContext(ServletContext context) {
		this.context = context;
	}



	public boolean isRenderReject() {
		return renderReject;
	}



	public void setRenderReject(boolean renderReject) {
		this.renderReject = renderReject;
	}



	public String getEMAIL_MESSAGE() {
		return EMAIL_MESSAGE;
	}



	public void setEMAIL_MESSAGE(String eMAIL_MESSAGE) {
		EMAIL_MESSAGE = eMAIL_MESSAGE;
	}



	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public EmployeeProjectDAO getEmployeeProjectDAO() {
		return employeeProjectDAO;
	}



	public void setEmployeeProjectDAO(EmployeeProjectDAO employeeProjectDAO) {
		this.employeeProjectDAO = employeeProjectDAO;
	}



	public EmployeeProject getEmployeeProject() {
		return employeeProject;
	}



	public void setEmployeeProject(EmployeeProject employeeProject) {
		this.employeeProject = employeeProject;
	}



	public List<EmployeeProject> getEmployeeProjects() {
		return employeeProjects;
	}



	public void setEmployeeProjects(List<EmployeeProject> employeeProjects) {
		this.employeeProjects = employeeProjects;
	}




	
	}
